﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class KhachHangBlo
    {
        #region "Khai báo các biến"
        private KhachHangDAO da;
        private KhachHangDTO _KH;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public KhachHangDTO KH
        {
            get { return _KH; }
            set { _KH = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public KhachHangBlo()
        {            
            da = new KhachHangDAO();
        }
        public bool InsertKH(string makh, string hoten, string sdt, string diachi, string email, int sofax, double congno, string masothue)
        {
            _KH = new KhachHangDTO(makh, hoten, sdt, diachi, email,sofax,congno,masothue);
            if (!da.InsertKH(KH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateKH(string makh, string hoten, string sdt, string diachi, string email, int sofax, double congno, string masothue)
        {
            _KH = new KhachHangDTO(makh, hoten, sdt, diachi, email, sofax, congno, masothue);
            if (!da.UpdateKH(KH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteKH(string maKH)
        {
            if (!da.DeleteKH(maKH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_KhachHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_KhachHang();
            return ds;
        }
        #endregion 
    }
}